home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / util / cli / ATT_awk_1_0.lha / AT&T-awk / ReadMe.amiga < prev    next >
Encoding:
Text File  |  1994-06-04  |  3.5 KB  |  96 lines

  1. Version 1.0 of a fully functional Amiga port of the April 22, 1994
  2. version of AT&T awk compiled with SAS/C 6.51.
  3. ------------------------------------------------------------------
  4.  
  5. The AT&T supplied code is 100% unchanged! The file "amiga.c" contains
  6. all the necessary adaptions to the AmigaDOS environment. 
  7.  
  8. I have run the "awk.g.y" and "awk.lx.l" files through yacc and lex
  9. respectively on an HP-UX workstation. The resulting C sources seem to
  10. build okay on the Amiga. The included smakefile does not attempt to
  11. recreate them. My advice is: do not delete "y.tab.c", "y.tab.h", and
  12. "lex.yy.c"!
  13.  
  14. To rebuild using SAS/C 6.51, just unpack the Amiga and AT&T source to
  15. the same directory and type smake.
  16.  
  17. Pipes are implemented in a very simplistic way. In fact they are not
  18. really pipes at all. Instead they are simulated using temporary files
  19. in the T: directory. This may change in the future, Matthew Dillon's
  20. FifoLib looks like a promising candidate.
  21.  
  22. The awk ENVIRON array holds copies of the local shell variables, but
  23. only under AmigaDOS 2.04+. Yes, awk should work with all versions of
  24. AmigaDOS.
  25.  
  26. Command line arguments are treated a bit differently than with most
  27. Amiga programs. Both the usual " as well as ' can be used to quote
  28. arguments:
  29.  
  30.   awk "BEGIN { *"date*" |getline d; print d }"
  31.   awk 'BEGIN { "date" |getline d; print d }'
  32.  
  33. Personally I tend to prefer the latter form, as it resembles the
  34. examples in A.V.Aho et al. "The AWK Programming Language". The escape
  35. character is the asterisk usually used in AmigaDOS. I tried using a
  36. backslash, but at least with WShell it caused more trouble than it is
  37. worth, because WShell (by necessity) tries to be clever about the
  38. contents of the command line.
  39.  
  40. Liberal use of escapes may be necessary when using single quotes,
  41. depending on which shell you use, e.g.,
  42.  
  43.   awk 'BEGIN { "date" *|getline d *; print d }'
  44.  
  45. The blanks before the asterisks are significant in WShell. If you
  46. don't want to bother with all these pitfalls, you can of course always
  47. put your script in a file and use the -f option...
  48.  
  49. Arguments are treated like AmigaDOS patterns, and expanded, if
  50.  
  51.   (1) they are not surrounded by single or double
  52.       quotes, and
  53.   (2) they contain at least one of the eight
  54.       characters "~#?*%([|", and
  55.   (3) awk is run under AmigaDOS V36+ OR arp.library
  56.       is installed.
  57.  
  58. The program works with pre-V36 AmigaDOS even if arp.library isn't
  59. installed, but it will not expand patterns. It will not attempt to
  60. open arp.library if running under V36+.
  61.  
  62. This example prints the total number of characters, words, and lines
  63. in the files in the current directory:
  64.  
  65.   awk "{ nc+=length($0)+1; nw+=NF} END { print nc, nw, NR }" #?.txt
  66.  
  67. With a little extra work, it can be turned into a clone of the UNIX wc
  68. command :-)
  69.  
  70. A word of warning. If an AmigaDOS pattern doesn't match any filenames,
  71. it expands to nothing, possibly causing an awk script to seem like
  72. it is hanging, while it is in fact just waiting for input from stdin.
  73. In that case you can just press Ctrl-\ (end of file).
  74.  
  75. Before I forget it, awk is pure and can be made resident.
  76.  
  77. Comments, questions and bug reports concerning this port can be sent
  78. to me at the following address:
  79.  
  80.    Torsten Poulin
  81.    Banebrinken 99, 2, 77
  82.    DK-2400 København NV
  83.    Denmark
  84.  
  85. or via e-mail: torsten@diku.dk (preferred)
  86.  
  87. Please note that my snail-mail address will change sometime this
  88. autumn. The Danish Mail will forward any letters to me for half a year
  89. after that, though.
  90.  
  91. Have fun,
  92. Torsten
  93.  
  94. P.S. awk is copyrighted by AT&T. Please refer to the copyright notices
  95. in the source and documentation files for details.
  96.